/*
堆区
    谁先创建 谁先构建
    谁先释放 谁先析构
栈区
    谁先创建 谁先构建
    和创建的顺序相反
*/
#include <iostream>
#include <string>

using namespace std;

int num = 1;

class stu
{
private:
    int val;
public:
    stu()
    {
        val = num++;
        cout << "我是：" << val << " 构建了" << endl; 
    }
    stu(int stu_val)
    {
        val = stu_val;
        cout << "我是：" << val << " 构建了" << endl; 
    }
    ~stu()
    {
        cout << "我是：" << val << " 析构了" << endl; 
    }
};

int main(int argc, char const *argv[])
{
    // 栈区
    // stu s1(1); 
    // stu s2(2); 
    // stu s3(3); 
    // stu s4(4); 

    // 堆区空间
    stu * s_p_1 =  new stu;
    stu * s_p_2 =  new stu;
    stu * s_p_3 =  new stu;
    stu * s_p_4 =  new stu;


    delete s_p_1;
    delete s_p_2;
    delete s_p_3;
    delete s_p_4;
    
    return 0;
}

